package com.elinshaw.pattern.latch;

import java.util.concurrent.TimeUnit;

public abstract class Latch {


    protected int limit;

    public Latch(int limit) {
        this.limit = limit;
    }

    public abstract void await() throws InterruptedException;

    /**
     * 可超时等待
     *
     * @param timeUnit
     * @param time
     * @throws InterruptedException
     * @throws WaitTimeOutException
     */
    public abstract void await(TimeUnit timeUnit, long time)
            throws InterruptedException, WaitTimeOutException;

    public abstract void countDown();

    /**
     * 获取多少线程没有完成任务
     */
    public abstract int unArrived();


}
